//
//  YYLVisitorTableViewController.swift
//  XinlangWeibo
//
//  Created by yangyinglei on 2017/3/27.
//  Copyright © 2017年 yangyinglei. All rights reserved.
//

import UIKit

class YYLVisitorTableViewController: UITableViewController {
    //是否登录的全局变量
    var isLogin:Bool = YYLUserAccountViewModel.shareViewModel.isLogin
    //全局的访客视图
    var visitorView: YYLVisitorView?
    
    override func loadView() {
        if isLogin {      //如果登录了  就返回系统的tableView样式
        super.loadView()
            return
        } else {
        visitorView = YYLVisitorView()
            
            view = visitorView
            visitorView?.callBack = {
            self.openOAth()
            }
        loadNavItemView()
        }
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

    }
    
    //设置
    func loadNavItemView() {
        //直接调用自己封装的分来方法来获取UIBarButtonItem
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", target: self, action: #selector(registerButtonAction))
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", target: self, action: #selector(loginButtonAction))
    }
    
    func registerButtonAction() {
//        print("注册")
        openOAth()
    }
    func loginButtonAction() {
//        print("登录")
        openOAth()
    }
    
    func openOAth() {
//        print("弹出注册页面")
        let oathView = YYLOAuthViewController()
        let nav = YYLNavigationController(rootViewController: oathView)
        self.present(nav, animated: true, completion: nil)
        
    }
}
